from selenium.webdriver.common.by import By

from base.FrontBase.front_base import BasePage, BaseHandle


class HomePage(BasePage):
    def __init__(self):
        super().__init__()
        self.input_box = By.XPATH, "//*[@placeholder='请输入搜索关键字...']"
        self.search_btn = By.CSS_SELECTOR, ".ecsc-search-button"

    def find_input_box(self):
        return self.get_element(self.input_box)

    def find_search_btn(self):
        return self.get_element(self.search_btn)


class HomeHandle(BaseHandle):
    def __init__(self):
        self.home_page = HomePage()

    def input_content(self, text):
        self.input_text(self.home_page.find_input_box(), text)

    def click_search_btn(self):
        self.home_page.find_search_btn().click()


class HomeProxy:
    def __init__(self):
        self.home_handle = HomeHandle()

    def go_details_page(self, text):
        self.home_handle.input_content(text)
        self.home_handle.click_search_btn()



